﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
//2 thu vien duoc them vao
using Subgurim.Controles;
using System.Configuration;
//Du lieu
using System.Data;
using System.Data.Sql;
using System.Data.SqlClient;

public partial class _Default : System.Web.UI.Page 
{
    protected string fulladdress;
    public Truycapdulieu truycapdl = new Truycapdulieu();
    protected void Load_HCMcity(string Toado)
    {
        fulladdress = "Việt Nam";
        string skey = ConfigurationManager.AppSettings["googlemaps.subgurim.net"];
        GeoCode geocode;
        geocode = GMap1.getGeoCodeRequest(fulladdress);
        

        //lấy vĩ độ và kinh độ//geocode.Placemark.coordinates.lat, geocode.Placemark.coordinates.lng
        //var glatlng = new Subgurim.Controles.GLatLng(geocode.Placemark.coordinates.lat, geocode.Placemark.coordinates.lng);
        
        //Load google maps
        var glatlng = new Subgurim.Controles.GLatLng(Toado);
        GMap1.setCenter(glatlng, 6, Subgurim.Controles.GMapType.GTypes.Normal);

        // Chú thích vị trí tìm được
        var oMarker = new Subgurim.Controles.GMarker(glatlng);
       

        //Bản đồ thu nhỏ zoom
        //GMap1.addControl(new GControl(GControl.preBuilt.GOverviewMapControl));

        //Thanh Zoom
        //GMap1.addControl(new GControl(GControl.preBuilt.LargeMapControl));
        GMap1.addControl(new GControl(GControl.preBuilt.LargeMapControl3D));
        
        //Style Maps
        GMap1.addControl(new GControl(GControl.preBuilt.MapTypeControl));
        //GMap1.addControl(new GControl(GControl.preBuilt.HierarchicalMapTypeControl));

        //GMap1.addControl(new GControl(GControl.preBuilt.NavLabelControl));

        //Cho biet khoang cach Góc trái
        GMap1.addControl(new GControl(GControl.preBuilt.ScaleControl));

        //Thanh di chuyển t,p,t,dưới.
        //GMap1.addControl(new GControl(GControl.preBuilt.SmallMapControl));

        //zoom out va zoom in
        //GMap1.addControl(new GControl(GControl.preBuilt.SmallZoomControl3D));
        
        //Document note

        GInfoWindow window = new GInfoWindow(oMarker, fulladdress, true);
        GMap1.addInfoWindow(window);
        
    }
    
  
  
    protected void Page_Load(object sender, EventArgs e)
    {
        
        string Toado = Request.QueryString["Toado"];

        Load_HCMcity(Toado);

        Label2.Text = Lng_Kinhdo("32323,323233");

               
    }
    //public double Lng_kinhdo()
    //{
        
    //    return Lng;
    //}
    
    public string Lng_Kinhdo(string LngLat)
    {
        
        //GridView grd = new GridView();
        //grd.DataSource = truycapdl.TaoBang("Select * From Tbl_DiaDiem Where ID='"+ID+"'");
        //Lng=grd.voidSelectedRow[0].Cells[6].ToString();
        //Lng = truycapdl.TaoBang("Select Lng From Tbl_DiaDiem Where ID='" + ID + "'").ToString();
        //return Lng;

        string Lng="";
        string[] chuoi = new string [100]; 
        for (int i=0; i < LngLat.Length; i++)
        {
            if (chuoi[i] != ",")
            {
                Lng = Lng + chuoi[i];
            }
            else if (chuoi[i] == ",")
            {
                i = LngLat.Length;
            }
 
        }

        return Lng.Trim();
        

    }
    protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
    {
        DropDownList2.DataSource = truycapdl.TaoBang("Select ID, PhanLoai From PhanLoai Where ID_LV='" + DropDownList1.SelectedValue.ToString() + "'");
        DropDownList2.DataValueField = "ID";
        DropDownList2.DataTextField = "PhanLoai";
        DropDownList2.DataBind();
        
    }
    
}